package Ms

//
//import (
//	"database/sql"
//	"fmt"
//	"db2s/dataDispos"
//	"db2s/global"
//	"runtime"
//	"strconv"
//	"time"
//)
//
//type CountS struct {
//	Db                  map[string]*sql.DB
//	DBTypeName          string
//	Drive               string
//	Schema              string
//	Table               string
//	ForceWhere          string //强制的where条件
//	QueueSize           int
//	IndexColumnName     []string
//	TableColumn         []map[string]string
//	ConnM               map[string]*sql.DB
//	TableLimit          int64
//	ChanRowCount        int
//	SqlExecStopTime     time.Duration
//	IndexColumnDataType string
//}
//
///*
//Oracle 查询有索引表的总行数
//*/
//func (or *CountS) tableCount(db map[string]*sql.DB, logseq int64) (int64, error) {
//	var (
//		tmpTableCount int64
//		tableData     map[string]interface{}
//		strsql        string
//		event         = "[tableCount]"
//		execTimeout   int64
//		err           error
//	)
//	pc, _, _, _ := runtime.Caller(1)
//	callingFunc := runtime.FuncForPC(pc)
//	callFile, callLine := callingFunc.FileLine(pc)
//	callFunc := callingFunc.Name()
//	callFuncInfo := fmt.Sprintf("Call functions %v Call File %v:%v", callFunc, callFile, callLine)
//
//	vlog = fmt.Sprintf("(%d) [%s] Start to query the total number of rows in the following table %s.%s of the %s database.", logseq, event, or.Schema, or.Table, DBType)
//	global.Wlog.Debug(vlog)
//	if len(or.ForceWhere) > 0 {
//		strsql = fmt.Sprintf("select /*+ parallel(16) */ count(1) as \"sum\" from \"%s\".\"%s\" where %s", or.Schema, or.Table, or.ForceWhere)
//	} else {
//		strsql = fmt.Sprintf("select /*+ parallel(16) */ count(1) as \"sum\" from \"%s\".\"%s\"", or.Schema, or.Table)
//	}
//	dispos := dataDispos.InstanceActiveS{DBType: DBType, LogThreadSeq: logseq, Event: event, DB: db["single"]}
//	var f1 any
//	if execTimeout, f1, err = dispos.SqlQuery(strsql, "map"); err != nil {
//		vlog = fmt.Sprintf("(%d) %v %v The execution of a sql statement failed. sql is {%v},error is {%v}", logseq, callFuncInfo, event, strsql, err)
//		global.Wlog.Error(vlog)
//		return 0, err
//	}
//	vlog = fmt.Sprintf("(%d) %v %v A sql statement was executed successfully. sql is {%v}, exec timeout is {%vms}", logseq, callFuncInfo, event, strsql, execTimeout)
//	global.Wlog.Debug(vlog)
//	if f1 != nil {
//		tableData = f1.(map[string]interface{})
//		if v, ok := tableData["sum"]; ok {
//			if d, err := strconv.ParseInt(fmt.Sprintf("%s", v), 10, 64); err == nil {
//				tmpTableCount = d
//			}
//		}
//	}
//	vlog = fmt.Sprintf("(%d) [%s] The query of the total number of rows in the following table %s.%s of the %s database is completed.", logseq, event, or.Schema, or.Table, DBType)
//	global.Wlog.Debug(vlog)
//	return tmpTableCount, nil
//}
//
//func (or CountS) CountIndexCheck() (dd chan *int64, mqSwitch bool) {
//	dd = make(chan *int64, 1)
//	go func() {
//		if dc, err := or.tableCount(or.Db, 1); err != nil {
//			fmt.Println(err)
//		} else {
//			dd <- &dc
//			close(dd)
//		}
//	}()
//	return dd, false
//}
//func (or CountS) IndexConcurrentQuery(_, _ int64, _ map[string]string, _ string) chan any {
//	return nil
//}
//func (or CountS) CountIsSegmentQuery(_, _ string) (s chan any) {
//	return
//}
//func (or CountS) IndexColumnPartQuryGroupCount1(_ map[string]string, _ string, _ int64) (D int64, err error) {
//	return
//}
//func (or CountS) CountMissIndexCheck() (dd *int64, mqSwitch bool) {
//	if dc, err := or.tableCount(or.Db, 1); err != nil {
//		fmt.Println(err)
//	} else {
//		dd = &dc
//	}
//	return
//}
